package com.wen.controller;

import com.wen.bean.UserInfoBean;
import com.wen.model.UserModel;
import com.wen.uilts.MyUilts;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/DeleteJump")
public class UserInfoDeleteServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取表单数据
        String strId = req.getParameter("id");
        //调用service进行删除操作
        //物理删除
        //int i = MyUilts.getNewInstance(UserModel.class).deleteUserById(strId);
        //逻辑删除
        int i = MyUilts.getNewInstance(UserModel.class).logicallyDeleteUserById(strId);

        //查询所有数据
        List<UserInfoBean> listUser = MyUilts.getNewInstance(UserModel.class).queryUserInfoAll();
        //存储到session
        req.getSession().setAttribute("lstUser", listUser);
        //跳转到查询页面
        req.getRequestDispatcher("WEB-INF/viewPages/userInfoB/UserInfoAddDetail.jsp").forward(req, resp);
    }
}
